<template>
    <div class="menu-expanded" :class="collapsed ? 'iscollapsed' : 'nocollapsed'">
        <div class="avatars">
            <div class="avatarImg logo">药品登记系统</div>
        </div>
        <el-scrollbar style="flex: 1">
            <el-menu
                :default-active="activeMenu"
                class="el-menu-vertical-demo"
                unique-opened
                router
                background-color="#1F2942"
                text-color="#C0C4CC"
                :collapse="collapsed"
                active-text-color="#fff"
                :collapse-transition="false"
            >
                <template v-for="(item, index) in $router.options.routes" v-if="!item.hidden">
                    <el-submenu :index="index + ''" v-if="!item.leaf" :key="item.name">
                        <template slot="title">
                            <i :class="item.icon"></i>
                            <span slot="title">{{ item.meta.title }}</span>
                        </template>
                        <el-menu-item v-for="child in item.children" :index="child.path" :key="child.path" v-if="!child.hidden">
                            {{ child.meta.title }}
                            <!-- <el-badge class="cmark" :value="sycount" :max="99" v-if="child.meta.title == '事由审批' && sycount > 0" />
                            <el-badge class="cmark" :value="ylcount" :max="99" v-if="child.meta.title == '预领审批' && ylcount > 0" />
                            <el-badge class="cmark" :value="bxcount" :max="99" v-if="child.meta.title == '报销审批' && bxcount > 0" />
                            <el-badge class="cmark" :value="apcount" :max="99" v-if="child.meta.title == '预领打款' && apcount > 0" /> -->
                        </el-menu-item>
                    </el-submenu>
                    <!-- 只有一个节点 -->
                    <el-menu-item v-if="item.leaf && item.children.length > 0" :index="item.children[0].path" :key="item.meta.title">
                        <i :class="item.icon" ></i>
                        <span slot="title">{{ item.children[0].meta.title }}</span>
                    </el-menu-item>
                </template>
            </el-menu>
        </el-scrollbar>
        <div class="collapse" @click="collapsedfun" :style="{ transform: 'rotateZ(' + (collapsed ? '-180' : '0') + 'deg)' }">
            <i class="iconfont iconjiantou1"></i>
        </div>
    </div>
</template>

<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
import Bus from '@/common/util/bus';
import store from '@/vuex/index';
@Component({
    components: {},
})
export default class SideBar extends Vue {
    public collapsed: boolean = false;
    public admin: boolean = false;
    public userName: string = '';
    public enterpriseLogoImgUrl: string = '';

    public mounted() {}
    get activeMenu() {
        const route = this.$route;
        const { meta, path } = route;
        if (meta.activeMenu) {
            return meta.activeMenu;
        }
        return path;
    }
    clear() {
        sessionStorage.clear();
    }
    collapsedfun() {
        this.collapsed = !this.collapsed;
    }
}
</script>
<style lang="scss" scoped>
// .menu-expanded{
//   width: 200px;
// }
.iconstyle {
    display: inline-block;
    width: 40px;
    text-align: left;
}
// .el-menu-vertical-demo .iconfont {
//     font-size: 16px;
// }
.collapse {
    background: rgba($color: #fff, $alpha: 0.5);
    text-align: center;
    height: 36px;
    width: 20px;
    line-height: 30px;
    font-size: 18px;
    cursor: pointer;
    position: absolute;
    bottom: 50%;
    right: 0px;
    border-radius: 2px 0 0 2px;
    display: none;
    img {
        width: 15px;
    }
}
.menu-expanded:hover {
    .collapse {
        display: inline-block;
    }
}
.iscollapsed .collapse {
    text-align: center;
}
.is_bottom {
    right: 0;
    bottom: 50%;
}
.is_top {
    top: 44px;
    right: -20px;
    background: rgba($color: #000000, $alpha: 0.1);
}
.iconjiantou1 {
    font-size: 10px;
    color: #333;
}
.iconlogo {
    font-size: 42px;
}
.logo {
    font-size: 18px;
    font-weight: bold;
}
.counttag {
    width: 12px;
    height: 12px;
    background: $red;
    padding: 3px;
    border-radius: 50%;
    text-align: center;
    font-size: 10px;
}
/deep/ .el-badge.cmark {
    margin-left: 10px;
    margin-bottom: 5px;
}
// /deep/ .el-scrollbar {
//     height: 100%;
//     .el-scrollbar__wrap {
//         overflow-x: hidden;
//     }
// }
</style>
